import java.awt.* ;
import java.awt.List;
import java.awt.event.* ;
import java.util.*;
import javax.swing.* ;


public class PreferencesDialog extends JPanel{
	
	private JComboBox foodTypeList;
	private JButton searchButton;
	private JCheckBox cheapButton;
	private JCheckBox affordableButton;
	private JCheckBox expensiveButton;
	private JCheckBox breakfastButton;
	private JCheckBox lunchButton;
	private JCheckBox brunchButton;
	private JCheckBox dinnerButton;
	private JCheckBox desertButton;
	private JCheckBox romanticButton;
	private JCheckBox casualButton;
	private JCheckBox businessButton;
	private JCheckBox festiveButton;
	private JCheckBox quiteButton;
	private JCheckBox twentyFourHrsButton;
	private JCheckBox deliveryButton;
	private JCheckBox sitDownButton;
	private JCheckBox driveThroughButton; 
	private JCheckBox takeOutButton;
	
	private ButtonGroup costGroup = new ButtonGroup();	
	private ButtonGroup mealGroup = new ButtonGroup();	
	private ButtonGroup typeGroup = new ButtonGroup();	
	private ButtonGroup moodGroup = new ButtonGroup();	
	
    JPanel zipCodeRow = new JPanel();
	JPanel foodTypeRow = new JPanel();
	JPanel preferencesRow = new JPanel();
	
	public Constants cons;
	
	//private domainLogic dL;
	
	
	public PreferencesDialog(){
		this.setLayout(new GridLayout(0,1));
		
	   
       foodTypeRow.setLayout(new BoxLayout(foodTypeRow, BoxLayout.Y_AXIS));
       
       preferencesRow.setLayout(new BoxLayout(preferencesRow, BoxLayout.X_AXIS));
       
       
		// ----------------- preferences elts ----------------------------------
		
		//cost group buttons
		JPanel costGroupCol = new JPanel();
		costGroupCol.setLayout(new BoxLayout(costGroupCol, BoxLayout.Y_AXIS));
		cheapButton = new JCheckBox("Cheap (< $10)");
	    affordableButton = new JCheckBox("Affordable ($10-$20)");	
		expensiveButton = new JCheckBox("Expensive (> $20)");
		costGroupCol.add(cheapButton);
		costGroupCol.add(affordableButton);
		costGroupCol.add(expensiveButton);
		preferencesRow.add(costGroupCol);
			
		//meal group buttons
		JPanel mealGroupCol = new JPanel();
		mealGroupCol.setLayout(new BoxLayout(mealGroupCol, BoxLayout.Y_AXIS));
		breakfastButton = new JCheckBox("Breakfast");
		lunchButton = new JCheckBox("Lunch");
		brunchButton = new JCheckBox("Brunch");
		dinnerButton = new JCheckBox("Dinner");
		desertButton = new JCheckBox("Desert");
		mealGroupCol.add(breakfastButton);
		mealGroupCol.add(lunchButton);
		mealGroupCol.add(brunchButton);
		mealGroupCol.add(dinnerButton);
		mealGroupCol.add(desertButton);
		preferencesRow.add(mealGroupCol);
		

		//mood group buttons
		JPanel romanticGroupCol = new JPanel();
		romanticGroupCol.setLayout(new BoxLayout(romanticGroupCol, BoxLayout.Y_AXIS));
		romanticButton = new JCheckBox("Romantic");
		casualButton = new JCheckBox("Casual");
		businessButton = new JCheckBox("Business");
		festiveButton = new JCheckBox("Festive");
		quiteButton = new JCheckBox("Quite");
		romanticGroupCol.add(romanticButton);
		romanticGroupCol.add(casualButton);
		romanticGroupCol.add(businessButton);
		romanticGroupCol.add(festiveButton);
		romanticGroupCol.add(quiteButton);
		preferencesRow.add(romanticGroupCol);
		
		//type group buttons
		JPanel typeGroupCol = new JPanel();
		typeGroupCol.setLayout(new BoxLayout(typeGroupCol, BoxLayout.Y_AXIS));
		twentyFourHrsButton = new JCheckBox("24 hrs");
		deliveryButton = new JCheckBox("Delivery");
		sitDownButton = new JCheckBox("Sit Down");
		driveThroughButton = new JCheckBox("Drive Thru");
		takeOutButton = new JCheckBox("Take out");
		typeGroupCol.add(twentyFourHrsButton);
		typeGroupCol.add(deliveryButton);
		typeGroupCol.add(sitDownButton);
		typeGroupCol.add(driveThroughButton);
		typeGroupCol.add(takeOutButton);
		preferencesRow.add(typeGroupCol);

		this.add(preferencesRow);
	}
		
	
	public JButton getSearchButton(){
		return searchButton;
	}
	

	public String getFoodType(){
		return (String)foodTypeList.getSelectedItem();
	}
	
	public Preferences getPreferences(){
		Preferences prefs = new Preferences();
			
		// check which preferences are chosen
		
		//------------cost------------
		if(cheapButton.isSelected()){
			prefs.addCost(Constants.CHEAP);
		}
		
		if(affordableButton.isSelected()){
			prefs.addCost(Constants.AFFORDABLE);
		}
		
		if(expensiveButton.isSelected()){
			prefs.addCost(Constants.EXPENSIVE);
		}
		
		
		//------------- meal ------------
		if(breakfastButton.isSelected()){
			prefs.addCost(Constants.BREAKFAST);
		}
		
		if(lunchButton.isSelected()){
			prefs.addCost(Constants.LUNCH);
		}
		
		if(dinnerButton.isSelected()){
			prefs.addCost(Constants.DINNER);
		}
		
		if(brunchButton.isSelected()){
			prefs.addCost(Constants.BRUNCH);
		}
		
		if(desertButton.isSelected()){
			prefs.addCost(Constants.DESSERT);
		}
		
		//-------------------- mood
		if(romanticButton.isSelected()){
			prefs.addCost(Constants.ROMANTIC);
		}
		
		if(businessButton.isSelected()){
			prefs.addCost(Constants.BUSINESS);
		}
		
		if(casualButton.isSelected()){
			prefs.addCost(Constants.CASUAL);
		}
		
		if(festiveButton.isSelected()){
			prefs.addCost(Constants.FESTIVE);
		}
		
		if(quiteButton.isSelected()){
			prefs.addCost(Constants.QUIET);
		}
		
		//--------------- type
		if(twentyFourHrsButton.isSelected()){
			prefs.addCost(Constants._24HRS);
		}
		
		if(driveThroughButton.isSelected()){
			prefs.addCost(Constants.DRIVETHRU);
		}
		
		if(deliveryButton.isSelected()){
			prefs.addCost(Constants.DELIVERY);
		}
		
		if(sitDownButton.isSelected()){
			prefs.addCost(Constants.SITDOWN);
		}
		
		
		return prefs;
	}
	
	
}